<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');

class backupControl extends Control {

    function index() {
        $this->display();
    }
    function show(){
        $tree = dir::tree("./backup");
//        echo date("Ymdhis")."<br/>";
//        echo date("Y-m-d h:i:s",20130201045811);exit;
        $this->assign("tree",$tree);
        $this->display();
    }
    //数据库还原
    function recovery(){
           $dir = $_GET['dir'];
           backup::recovery(array(
               "dir" => "./backup/".$dir,
               "url" => "__success",
               "step_time"=>0,
               )
           );
    }
    function __success(){
        $this->success("操作成功","show");
    }
    function back() {

        $config = include "./config/backup.php";

        Backup::backup(array(
            "url" => "show",
            "dir" => "./backup/" .NOW,
            "step_time"=>$config['backup_step_time'],
            "row"=>$config['backup_row']
        ));
    }
    function editconfig(){
        // p($_POST);die;
        $config = var_export($_POST,true);
        $str="<?php\nif(!defined('PATH_HD'))exit;\n return ";
        $str.=$config.";\n?>";
        file_put_contents("./config/backup.php",$str);
        go("back");
    }

}

?>
